package org.samoji.sji.model;

import java.math.BigDecimal;

import org.samoji.sji.profTokenizer.Token.Type;

public class UnExpr extends Expr {
	protected Type operation;
	protected Expr expr;
	
	public UnExpr(Type operation, Expr expr) {
		this.operation = operation;
		this.expr = expr;
	}
	
	@Override
	public BigDecimal evaluate(Env env) {
		switch(operation) {
		case Plus:
			return new PlusUnExpr(expr).evaluate(env);
			
		case Minus:
			return new MinusUnExpr(expr).evaluate(env);
			
		default:
			throw new RuntimeException("run-time: unary expression not implemented");
		}
	}
}